def is_leap(year): 
    if year % 400 != 0 and year % 100 ==0 or year % 4 != 0:
        return False
    return True


def days_of_month(date_str):
    dlist = [31,28,31,30,31,30,31,31,30,31,30,31]
    year = int(date_str[0:4])  
    if is_leap(year): dlist[1]=29
    return dlist[int(date_str[5:6])-1]


date_in = input()

print(days_of_month(date_in))